package cn.wowjoy.commonlibrary.utils;

import android.text.TextUtils;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by sugar on 2018/4/26.
 */

public class DateUtils {


    public static String getTodayFormat() {
        Date date = new Date();
        String mat = "yyyy-MM-dd";
        SimpleDateFormat format = new SimpleDateFormat(mat);
        String nowdate = format.format(date);
        DebugUtil.error("nowdate", nowdate + "//");
        return nowdate;
    }


    public static String getWorkDayFormat(String time) {
        if (!TextUtils.isEmpty(time)) {
            String[] split = time.split(" ");
            if (split.length == 2) {
                return split[0];
            }
        }
        return null;
    }

    public static String  getSurgertDate(String date){
        if (!TextUtils.isEmpty(date)) {
            int i = date.lastIndexOf(":");
            return date.substring(0, i);
        }
        return null;

    }

    public static String getCurrFullDay() {
        SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd");
        return sDateFormat.format(new Date());
    }

    public static String getCurrFullTime() {
        SimpleDateFormat sDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return sDateFormat.format(new Date());
    }

    public static String getFormateTime(String time, String T) {
        SimpleDateFormat sDateFormat = new SimpleDateFormat(T);
        try {
            return sDateFormat.format(sDateFormat.parse(time));
        } catch (ParseException e) {
            return "";
        }
    }
}
